#!/usr/bin/perl -w
print "Please enter a string:";
chomp(my $string = <STDIN>);
print "Please enter a substring:";
chomp(my $sub = <STDIN>);

my @placse;

for (my $pos = -1; ;) {
    $pos = index($string, $sub, $pos + 1);
    last if $pos == -1;
    push @places, $pos;
}

print "Loaction of '$sub' in '$string' were：@places\n";

